Skip to content

Conversation

@ckcks12
Copy link
Contributor

@ckcks12 ckcks12 commented Oct 1, 2019

#1464

From
image

To
image

Algorithm

Sort them by Earlier -> Up, Longer -> Left.
And then group them who are being overlapped each other.
And give number by order then stretch them to the same size except the last one. last one could be greedy like he can eat all the rest place!

Performance

200 of random events

original

image

with new algorithm

image

1000 of random events

original

image

with new algorithm

image

About the Optimization

I leave some comments like TODO where further optimization would be effective.
But as you can see above Performance Metrics, even a thousand of events doesn't affect much.
in case you want to know how A THOUSAND of events looks like,
image

The source might be kinda dirty and hard to read because I hardly use the map() for loop which would be prettier. Honestly it causes a performance issue. Here you can find why I used for.
https://github.com/dg92/Performance-Analysis-JS

And...

I put some more like padding between events. like 2px between them.
I think it's prettier but also worry bout it's hard coded.

Copy link
Contributor Author

@ckcks12 ckcks12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

@KhaledMohamedP
Copy link
Contributor

@ckcks12 Great job 👏

This PR addressees #1440

@beaugunderson
Copy link

@ckcks12 this looks great; we're very excited about getting this merged!

@jquense
Copy link
Owner

jquense commented Oct 3, 2019

thanks for doing this, hoping to get some time to review in the next few days!

@KhaledMohamedP
Copy link
Contributor

KhaledMohamedP commented Oct 8, 2019

Looks like a lot of people are waiting for this PR to be merge! @jquense, did you get a chance to review this PR?

Appreciate your time and help here 🙏

@np2010
Copy link

np2010 commented Oct 8, 2019

Nice fix. I also need to have a couple of more enhancement in UI. I hope the community welcomes them as well.

Copy link
Owner

@jquense jquense left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there! Had quick, functionally this looks ok, but the structure isn't acceptable at the moment. There seems like there is a lot of redundant work done in getStyledEvents and then deleted or altered in DayColumn. No layout work should be in DayColumn, that's why DayEventLayout exists.

I would add dayLayoutAlgorithm a as prop and provide two options, the current overlapping, and non overlapping implementations. Each implementation should be its own file and essentially just export getStyledEvents which should be the main API area for doing this. That way we can also allow users to provide their own function for dayLayoutAlgorithm if they want customized logic

src/DayColumn.js Outdated
import TimeSlotGroup from './TimeSlotGroup'
import TimeGridEvent from './TimeGridEvent'

function dfs(node, maxIdx, visited) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't abbreviate the name plz

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okayy.

Comment on lines +114 to +161
{
id: 16,
title: 'Video Record',
start: new Date(2015, 3, 14, 15, 30, 0),
end: new Date(2015, 3, 14, 19, 0, 0),
},
{
id: 17,
title: 'Dutch Song Producing',
start: new Date(2015, 3, 14, 16, 30, 0),
end: new Date(2015, 3, 14, 20, 0, 0),
},
{
id: 18,
title: 'Itaewon Halloween Meeting',
start: new Date(2015, 3, 14, 16, 30, 0),
end: new Date(2015, 3, 14, 17, 30, 0),
},
{
id: 19,
title: 'Online Coding Test',
start: new Date(2015, 3, 14, 17, 30, 0),
end: new Date(2015, 3, 14, 20, 30, 0),
},
{
id: 20,
title: 'An overlapped Event',
start: new Date(2015, 3, 14, 17, 0, 0),
end: new Date(2015, 3, 14, 18, 30, 0),
},
{
id: 21,
title: 'Phone Interview',
start: new Date(2015, 3, 14, 17, 0, 0),
end: new Date(2015, 3, 14, 18, 30, 0),
},
{
id: 22,
title: 'Cooking Class',
start: new Date(2015, 3, 14, 17, 30, 0),
end: new Date(2015, 3, 14, 19, 0, 0),
},
{
id: 23,
title: 'Go to the gym',
start: new Date(2015, 3, 14, 18, 30, 0),
end: new Date(2015, 3, 14, 20, 0, 0),
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are for overlapping situation

top: stringifyPercent(top),
[rtl ? 'right' : 'left']: stringifyPercent(xOffset),
width: stringifyPercent(width),
height: stringifyPercent(height),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometimes the algorithm needs calc() so I just made it as 'string' || 'number'. number will be followed by %.

Maybe you think it is no good that I didn't make it all string only. Frankly I tried it but you know that plain css string is quite annoying for testing, right?

image

I also tried to parse() and floor() but... yeah... too much. so this is why.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its fine 👍

@ckcks12
Copy link
Contributor Author

ckcks12 commented Oct 10, 2019

@jquense Hallo~

I made it as strategy pattern like pluggable design. 😆

DayEventLayout.js -> layout-algorithms/overlap.js or layout-algorithms/no-overlap.js

And from the top of the library, the Calendar, I made new attribute dayLayoutAlgorithm and its prop type is overlap | no-overlap | Function.

and also I created a demo section for no-overlap algorithm.
image

Sooooooo hope you like it 👀

@jquense
Copy link
Owner

jquense commented Oct 10, 2019

just need a moment to try it out then gtg

@KhaledMohamedP
Copy link
Contributor

@jquense did you find any blockers?

@Canuckaholic
Copy link

Very excited for this! Thanks for all the work on this everyone involved.

@Dragomir-Ivanov
Copy link
Contributor

Having overlap strategy as an option to Calendar would be very helpful. I also need all events visible at the cost of ugly presentation.

@jquense jquense merged commit e622651 into jquense:master Oct 17, 2019
@KhaledMohamedP
Copy link
Contributor

@jquense Thanks for merging :)

Can we please push this to npm and increment the package version as a MINOR update?

Looking forward to this update 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants